<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
            .box1{
             
             height: 100px;
             background-color: aqua;   
            }
            .box1::before{
                content: "GGG";
                color:blue;
            }
    </style>
</head>
<body>
    <button id="btn">点</button>
    <hr />
    <div class="box1">
        
    </div>
<script>

        const box1 = document.querySelector("div.box1")
        console.log(box1);
        const btn = document.getElementById("btn")
        console.log(btn);
        btn.addEventListener("click",function(){
            /* 
                getComputedStyle()
                    - 它会返回一个对象,对象包含当前元素所有生效的样式
                    - 参数:
                        1.要获取样式的对象
                        2.要获取的伪元素
                    - 返回值:
                        返回的是一个对象,对象中存储了当前元素的原始
                    - 注意:
                        样式对象中返回的样式值,不一定能拿来直接计算
                            所以使用的时候,一定要确保是可以计算的采取计算
                        
            */
           const box1obj =  getComputedStyle(box1)
            console.log(box1obj.height);
            box1.width = parseInt(box1.width) + 100
            console.log(box1obj.width);
            const box1beforeobj = getComputedStyle(box1,"::before")
            console.log(box1beforeobj.color);
            console.log(box1obj.left);
            box1.left = parseInt(box1.left) + 100
        })
        
</script>
</body>
</html>